﻿using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using OnWork.Admin.DAL;
using OnWork.Admin.DAL.System;
using OnWork.Admin.Util.Base;

namespace OnWork.Admin.BLL.System
{
    public class DemoBLL : BaseBLL<DemoEntity>, IScoped
    {
        private readonly DBManage _dBManage;

        private readonly IHttpContextAccessor _accessor;

        /// <summary>
        /// 注入系统库
        /// </summary>
        /// <param name="dBManage"></param>
        public DemoBLL(DBManage dBManage, IHttpContextAccessor accessor) : base(dBManage.System)
        {
            _dBManage = dBManage;
            _accessor = accessor;
        }

        /// <summary>
        /// 获取token测试
        /// </summary>
        public object GetToken()
        {
            var db = ServiceLocator.Instance.GetService<DBManage>();

            var content = ServiceLocator.Instance.GetService<IHttpContextAccessor>();
            return content.HttpContext.GetTokenAsync("access_token");
            //return _accessor.HttpContext.GetTokenAsync("access_token");
        }
    }
}